package com.itheima.controller;


import com.itheima.common.JsonResult;
import com.itheima.common.SnowFlake;
import com.itheima.pojo.client.selectDishListVo.SelectDishListVo;
import com.itheima.service.DishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ChenJunJie
 * @date 2022/6/18 17:23
 * 菜品列表controller层
 */
@RestController
@RequestMapping(value = "/dish", produces = "application/json;charset=utf-8")
public class DishController {

    @Autowired
    private SnowFlake snowFlake;
    @Autowired
    private RedisTemplate<String, String> redisTemplate;
    @Autowired
    private DishService dishService;

    //查询菜品列表
    @GetMapping("/list")
    public JsonResult<List<SelectDishListVo>> selectDishList (@RequestParam("categoryId") String categoryId , @RequestParam("status") Integer status) {
        List<SelectDishListVo> selectDishListDtos =dishService.selectDishList(categoryId,status);

        if (selectDishListDtos.size()>0){
            return JsonResult.employeePaginationSuccess(selectDishListDtos,"查询成功");
        }else {
            return JsonResult.employeePaginationError(selectDishListDtos,"暂无数据");
        }
    }

}
